<template>
    <div class="search-container">
        <div class="search-header">
            <div class="header-actions">
                <el-button @click="goToHome">
                    <el-icon>
                        <HomeFilled />
                    </el-icon>
                    返回首页
                </el-button>
            </div>
        </div>
        <iframe src="https://ai.betteryeah.com/chat/a8e338ce769a478daa5a49f6011776e6" frameborder="0" class="search-frame" @load="handleIframeLoad"></iframe>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { HomeFilled } from '@element-plus/icons-vue'

const router = useRouter()

const goToHome = () => {
    router.push('/home')
}

const handleIframeLoad = () => {
    // 可以在这里添加iframe加载完成后的处理逻辑
    console.log('Baidu search page loaded')
}
</script>

<style lang="scss" scoped>
.search-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #fff;
    z-index: 1000;
    display: flex;
    flex-direction: column;

    .search-header {
        padding: 10px 20px;
        background-color: #fff;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
        z-index: 1;

        .header-actions {
            display: flex;
            justify-content: flex-end;
        }
    }

    .search-frame {
        flex: 1;
        width: 100%;
        height: calc(100vh - 60px); // 减去header的高度
        border: none;
    }
}
</style>